home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABUSESRC.ZIP / AbuseSrc / macabuse / inc / chars.hpp < prev    next >
C/C++ Source or Header  |  1997-05-20  |  4KB  |  138 lines

  1. #ifndef __CHARACTERZ_HPP_
  2. #define __CHARACTERZ_HPP_
  3.  
  4.  
  5. #include "seq.hpp"
  6. #include "sound.hpp"
  7. #include "ability.hpp"
  8. #include "event.hpp"
  9. #include "macs.hpp"
  10. #include <stdarg.h>
  11. #include <time.h>
  12.  
  13.  
  14. enum character_state {dead,  
  15.               dieing,
  16.               stopped,              
  17.               start_run_jump,run_jump, run_jump_fall, end_run_jump,
  18.               flinch_up,flinch_down,
  19.               morph_pose,
  20.               running
  21.             } ;
  22.  
  23.  
  24.  
  25. #define MAX_STATE (running+1)
  26. extern char *state_names[];
  27.  
  28. class named_field
  29. {
  30.   public :
  31.   char *real_name;
  32.   char *descript_name;
  33.   named_field(char *real, char *fake) 
  34.   { real_name=strcpy((char *)jmalloc(strlen(real)+1,"var_name"),real); 
  35.     descript_name=strcpy((char *)jmalloc(strlen(fake)+1,"var_name"),fake); 
  36.   }
  37.   ~named_field() { jfree(real_name); jfree(descript_name); }
  38. } ;
  39.  
  40.  
  41.  
  42. // all cflags default is 0
  43. #define TOTAL_CFLAGS 11
  44. enum { CFLAG_HURT_ALL,            // if object hurts all characters, not just player
  45.        CFLAG_IS_WEAPON,           // if object is a collectable weapon (should have a logo)
  46.        CFLAG_STOPPABLE,           // if object can be stopped by any other object
  47.        CFLAG_CAN_BLOCK,           // if object can block other object
  48.        CFLAG_HURTABLE,
  49.        CFLAG_PUSHABLE,            // can push other pushable characters
  50.        CFLAG_UNLISTABLE,          // if object should appear in object list during edit mode
  51.        CFLAG_ADD_FRONT,
  52.        CFLAG_CACHED_IN,
  53.        CFLAG_NEED_CACHE_IN,
  54.        CFLAG_UNACTIVE_SHIELD      // if object is not active (i.e. link 0 aistate==0) 
  55.                                   // then objects will not draw a damage when hitting it
  56.      };
  57. extern char *cflag_names[TOTAL_CFLAGS];
  58.  
  59. // all object functions default to NULL
  60. #define TOTAL_OFUNS 11
  61. enum { OFUN_AI,                   // objects ai function called by the mover, should call (tick)
  62.        OFUN_MOVER,                // objects move function, gets x y and but
  63.        OFUN_DRAW,
  64.        OFUN_MAP_DRAW,
  65.        OFUN_DAMAGE,               // called when the object receives damage 
  66.        OFUN_NEXT_STATE,           // called at the end of an object sequence
  67.        OFUN_USER_FUN,             // can by called (user_fun x y z)
  68.        OFUN_CONSTRUCTOR,          // called when object is created, dev & play modes
  69.        OFUN_RELOAD,               // called when the object is loaded from disk (not save games)
  70.        OFUN_GET_CACHE_LIST,       // called on level load, should return list (a . b) a is character id, and b is other ids
  71.        OFUN_CHANGE_TYPE
  72.      } ;
  73. extern char *ofun_names[TOTAL_OFUNS];
  74.  
  75.  
  76. class character_type
  77. public :
  78.   ushort ts,tiv,tv; // total states, total index vars, total local vars
  79.   sequence **seq;   // [0..ts-1]
  80.   void **seq_syms;  // symbol describing what this state is [0..ts-1]
  81.  
  82.   void **vars;  // symbol describing variable names    [0..tiv-1]
  83.   short *var_index; // index into local var                [0..tiv-1]
  84.  
  85.   void add_var(void *symbol, void *name);
  86.   int add_state(void *symbol);              // returns index into seq to use
  87.   int abil[TOTAL_ABILITIES];
  88.   void *fun_table[TOTAL_OFUNS];             // pointers to lisp function for this object
  89.   int logo,morph_mask,morph_power; 
  90.   long rangex,rangey,draw_rangex,draw_rangey;             // range off screen before character is skipped
  91.  
  92.   ushort cflags;
  93.   void *get_fun(int name) { return fun_table[name]; }
  94.   int get_cflag(int name) { return cflags&(1<<name); }
  95.   void set_cflag(int name, int x) { if (x) cflags|=(1<<name);  else cflags&=~(1<<name); }
  96.   int total_fields;                         // used by game editor to replace field names  
  97.   named_field **fields;
  98.   character_type(void *args, void *name);   // lisp object describes object 
  99.  
  100.   sequence *get_sequence(character_state s);
  101.   void add_sequence(character_state which, sequence *new_seq); 
  102.   int has_sequence(character_state s) { return s<ts && (seq[s]!=NULL); }
  103.   int cache_in();    // returns false if out of cache memory
  104.   void check_sizes();
  105.   long isa_var_name(char *name);
  106.  
  107.   ~character_type();
  108. } ;
  109.  
  110. extern character_type **figures;
  111. int flinch_state(character_state state);
  112.  
  113. void *def_char(void *args);
  114.  
  115. extern int total_weapons;
  116. extern int *weapon_types;    // maps 0..total_weapons into 'real' weapon type
  117.  
  118. #endif
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.